﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using Digitalmes.Model;
using Digitalmes.Model.ProductionManagement;

namespace Digitalmes.Model.ProductionManagement
{
    /// <summary>
    /// 过程数据表
    /// </summary>
	[Table("ProductionArchiveData")]

    [Display(Name = "_Model.ProdArchiveData")]
    public class ProductionArchiveData : BasePoco,IPersistPoco,ITenant
    {
        [Key]
        [Display(Name = "_Model._ProdArchiveData._ID")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public new long ID { get; set; }
        [Display(Name = "_Model._ProdArchiveData._ArchiveId")]
        [Comment("数据源")]
        public ProductionArchive ArchiveId { get; set; }
        [Display(Name = "_Model._ProdArchiveData._ArchiveId")]
        [Comment("数据源")]
        public long? ArchiveIdId { get; set; }
        [Display(Name = "_Model._ProdArchiveData._DataTag")]
        [Comment("变量名称")]
        public string DataTag { get; set; }
        [Display(Name = "_Model._ProdArchiveData._DataName")]
        [Comment("数据名称")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string DataName { get; set; }
        [Display(Name = "_Model._ProdArchiveData._DataValue")]
        [Comment("数据值")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string DataValue { get; set; }



        public TagDataTypeEnum DataType { get; set; }

        [Display(Name = "_Model._ProdArchiveData._UpLimit")]
        [Comment("数据上限")]
        [Precision(18,3)]
        public decimal? UpLimit { get; set; }
        [Display(Name = "_Model._ProdArchiveData._LowerLimit")]
        [Comment("数据下限")]
        [Precision(18,3)]
        public decimal? LowerLimit { get; set; }
        [Display(Name = "_Model._ProdArchiveData._ProductCode")]
        [Comment("产品名称")]
        public string ProductCode { get; set; }
        [Display(Name = "_Model._ProdArchiveData._OpCode")]
        [Comment("工位编号")]
        public string OpCode { get; set; }
        [Display(Name = "_Model._ProdArchiveData._SetParameter")]
        [Comment("设置参数")]
        public string SetParameter { get; set; }
        [Display(Name = "_Model._ProdArchiveData._ProductId")]
        [Comment("产品号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public long? ProductId { get; set; }
        [Display(Name = "_Model._ProdArchiveData._OpId")]
        [Comment("工位号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public long? OpId { get; set; }


        [Display(Name = "_Model._ProcessResults._IntervalSeconds")]
        [Comment("采取频率(秒)")]
        [Range(1, 999999999, ErrorMessage = "Validate.{0}range{1}")]
        public int IntervalSeconds { get; set; } = 0;

        [Display(Name = "_Model._ProcessResults._SampleMode")]
        [Comment("采取方式")]
        public DataSampleEnum SampleMode { get; set; } = DataSampleEnum.SingleData;


        [Display(Name = "_Model._ProdArchiveData._Wo")]
        [Comment("工单")]
        public string Wo { get; set; }
        [Display(Name = "_Model._ProdArchiveData._Sn")]
        [Comment("追溯码")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public string Sn { get; set; }
        [Display(Name = "_Model._ProdArchiveData._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}

}
